package com.qf.dao;


import com.qf.dto.UserDto;
import com.qf.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lzy
 * @since 2020-11-28
 */
@Repository
public interface UserDao  {

    @Select("select * from t_user where phone=#{phone}")
    User selectByPhone(String phone);

    @Insert("insert into t_user (phone,password,flag) values(#{phone},#{password},1)")
    @Options(useGeneratedKeys = true,keyProperty = "id")//标记获取自增主键的值
    int insertGetId(User user);

    @Update("update t_user set password=#{password} where phone=#{phone}")
    int update(UserDto userDto);

    @Select("select * from t_user")
    List<User> selectList();
}
